#include "World.h"

World::World(void)
{
	xOffset = 0;
	yOffset = 0;

	gameEntityList.reserve(10000);


}

World::~World(void)
{
}


void World::add(GameEntity* e)
{
	gameEntityList.push_back(e);
}


void World::beginUpdate()
{
	for (std::vector<GameEntity*>::iterator it = gameEntityList.begin(); it!=gameEntityList.end(); ++it)
	{
		(*it)->update();
	}
}

void World::endUpdate()
{
	for (std::vector<GameEntity*>::iterator it = gameEntityList.begin(); it!=gameEntityList.end(); ++it) //change this to be dynamic only list, only moveable entities move, and only moveables collide
	{
		(*it)->commitMovement();
	}
}



void World::renderTopLayer(float interpolation)
{
	for (std::vector<GameEntity*>::iterator it = gameEntityList.begin(); it!=gameEntityList.end(); ++it)
	{

		(*it)->render(interpolation, xOffset, yOffset);
	}
}


/*


Top Layer Drawable
- Image i
- drawWith(Position p)
Position



or


WITH THIS METHOD WE CAN STILL REGISTER THINGS WITH THE WORLD. ENTITIES JUST UPDATE THE STUFF.
Entity
- List topLayerable
- List collidable
- void add(collidable)
- void add(topLayerable)
- void drawTopLayer
- List getCollidables //hmm, the question is how then to handle the moving back of collisions. Or maybe just have it keep the parent entity, this  might have to be done for sorting perhaps? Or have all entities able to sort somehow
- void updatePositionToCollidable
*/